using System;
using Engine;

namespace Game
{
	public struct RemotePlayerInput
	{
		public Nullable<Vector2> PickBlockType;

		public PlayerInteractType InteractType;

		public Nullable<Vector3> InteractDirection;

		public bool Lighting;

		public bool TimeOfDay;

		public bool Drop;

		public bool Jump;

		public bool IsSneaking;

		public bool IsCreativeFlying;

		public Vector3 Position;

		public Vector3 Velocity;

		public Quaternion Rotation;

		public Vector2 LookAngles;

		public float Health;

		public RemotePlayerInput(ComponentPlayer player)
		{
			PlayerInput playerInput = player.ComponentInput.PlayerInput;
			PickBlockType = playerInput.PickBlockType;
			InteractType = (PlayerInteractType)((playerInput.Interact.HasValue ? 1 : 0) | (playerInput.Hit.HasValue ? 2 : 0) | (playerInput.Aim.HasValue ? 4 : 0) | (playerInput.Dig.HasValue ? 8 : 0));
			Nullable<Vector2> interact = playerInput.Interact;
			Nullable<Vector2> obj;
			if (!interact.HasValue)
			{
				Nullable<Vector2> hit = playerInput.Hit;
				if (!hit.HasValue)
				{
					Nullable<Vector2> aim = playerInput.Aim;
					obj = (aim.HasValue ? aim : playerInput.Dig);
				}
				else
				{
					obj = hit;
				}
			}
			else
			{
				obj = interact;
			}
			Nullable<Vector2> vector = obj;
			if (vector.HasValue)
			{
				InteractDirection = player.View.ActiveCamera.ScreenToWorld(new Vector3(playerInput.Dig.Value, 1f), Matrix.Identity);
			}
			else
			{
				InteractDirection = null;
			}
			Lighting = playerInput.Lighting;
			TimeOfDay = playerInput.TimeOfDay;
			Drop = playerInput.Drop;
			Jump = playerInput.Jump;
			IsSneaking = player.ComponentBody.IsSneaking;
			IsCreativeFlying = player.ComponentLocomotion.IsCreativeFlyEnabled;
			Position = player.ComponentBody.Position;
			Velocity = player.ComponentBody.Velocity;
			Rotation = player.ComponentBody.Rotation;
			LookAngles = player.ComponentLocomotion.LookAngles;
			Health = player.ComponentHealth.Health;
		}

		public void Reset()
		{
		}
	}
}
